package vn.axonivy.vision.streams;

import java.util.ArrayList;
import java.util.List;

public class Matching {
	public static void main(String[] args) {
		/*
		 * Various matching operations can be used to check whether a certain
		 * predicate matches the stream. All of those operations are terminal
		 * and return a boolean result.
		 */
		List<String> memberNames = new ArrayList<>();
		memberNames.add("Amitabh");
		memberNames.add("Shekhar");
		memberNames.add("Aman");
		memberNames.add("Rahul");
		memberNames.add("Shahrukh");
		memberNames.add("Salman");
		memberNames.add("Yana");
		memberNames.add("Lokesh");

		boolean matchedResult = memberNames.stream().anyMatch(
				(s) -> s.startsWith("A"));

		System.out.println("anyMatch: " + matchedResult);

		matchedResult = memberNames.stream().allMatch((s) -> s.startsWith("A"));

		System.out.println("allMatch: " + matchedResult);

		matchedResult = memberNames.stream()
				.noneMatch((s) -> s.startsWith("A"));

		System.out.println("noneMatch: " + matchedResult);
	}
}
